<#include "/common/layout.html">
<@header>
</@header>
<@body>
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
      <small>系统管理 > 菜单管理</small>
    </h1>
  </section>
  <!-- Main content -->
  <section class="content">
     <div class="row">
      <div class="col-md-12">
        <!-- general form elements -->
        <div class="box box-primary">
          <div class="box-header with-border">
            <h3 class="box-title">编辑菜单</h3>
          </div><!-- /.box-header -->
          <!-- form start -->
          <div class="row">
          	<div class="col-md-6">
        	    <form role="form" data-validator-option="{theme:'bootstrap', timely:2, stopOnError:true}" method="post" action="/system/menu/doEdit.html">
		            <input type="hidden" name="id" value="${(sysMenu.id)!}" />
		            <div class="box-body">
		                <div class="form-group">
	                    <label>选择目录/菜单</label>
	                    <select id="dir" class="form-control select2" style="width: 100%;" data-rule="目录:required;">
	                      <option value="" selected="selected">--请选择--</option>
	                      <#list list as m>
	                      	 <option value="${(m.id)!}" <#if m.id==pSysMenu.pid> selected="selected" </#if> >${(m.code)!}-${(m.menuName)!}</option>
	                      </#list>
	                    </select>
	                    <select id="pid" name="pid" class="form-control select2" style="width: 100%;" data-rule="菜单:required;">
                    		<option value="${(pSysMenu.id)!}" selected="selected">${(pSysMenu.code)!}-${(pSysMenu.menuName)!}</option>
                  		</select>
				       </div>
		              <div class="form-group">
		                <label for="uname">功能名称</label>
		               	<input type="text" name="menuName" value="${(sysMenu.menuName)!}" class="form-control" placeholder="请输入目录名称"  data-rule="目录名称:required;">
		              </div>
		               <div class="form-group">
		                <label for="uname">编码</label>
		               	<input type="text" name="code" class="form-control" value="${(sysMenu.code)!}"
		               	placeholder="请输入编码,如050101" data-rule="required;number" data-rule-number="[/^\d{6}$/, '请输入6位数字编码']">
		              </div>
		              <div class="form-group">
		                <label for="resource">权限资源</label>
		               	<input type="text" id="resource" name="resource" value="${(sysMenu.resource)!}" class="form-control" placeholder="请输入权限资源名称"  
		               	data-rule="权限资源:required;">
		              </div> 
		              <div class="form-group">
		                <label for="uname">排序</label>
		               	<input type="text" name="sort" value="${(sysMenu.sort)!}" class="form-control" placeholder="请输入排序"  data-rule="排序:required;integer[+0]">
		              </div>
		            </div><!-- /.box-body -->
		            <div class="box-footer">
		              <button type="submit" class="btn btn-success"><i class="fa fa-save"></i>  提 交</button>
		              <a  class="btn btn-default" href="/system/menu/list/1.html"><i class="fa fa-close"></i>  取消</a>
		            </div>
		          </form>
            </div>
          	</div>
          </div>
        </div><!-- /.box -->
      </div><!--/.col (left) -->
  </section><!-- /.content -->
</div><!-- /.content-wrapper -->
</@body>
<@footer>
<script>
$("#dir").on('change',function(){
	var pid = $(this).val();
	 $.post('/system/menu/json?_dc='+new Date().getTime(),{pid:pid},function(response){
		if(response.meta && response.meta.success){
			$("#pid").empty();
			$("#pid").select2({
				data:response.data
			});
		}
	}); 
});
</script>
</@footer>